//
//  PopView.m
//  29-HomeWork
//
//  Created by 鹏飞罗 on 16/8/23.
//  Copyright © 2016年 罗鹏飞. All rights reserved.
//

#import "PopView.h"
#import "ViewController.h"
#import "SecondViewController.h"
@implementation PopView
- (NSTimeInterval)transitionDuration:(nullable id <UIViewControllerContextTransitioning>)transitionContext {
    return 1;
}
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
    SecondViewController *fromView = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
   ViewController *toView = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    UIView *containerView = [transitionContext containerView];
    
    [containerView addSubview:toView.view];
    toView.cell.myImageView.hidden = NO;
    
    UIView *guoduView = [fromView.imageView1 snapshotViewAfterScreenUpdates:YES];
    guoduView.frame = fromView.imageView1.frame;
    [containerView addSubview:guoduView];
    [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
        [containerView layoutIfNeeded];
        guoduView.frame = toView.cell.myImageView.frame;
    } completion:^(BOOL finished) {
       toView.cell.myImageView.hidden = NO;
       
        [guoduView removeFromSuperview];
        [transitionContext completeTransition:YES];
    }];
    
    
}
@end
